package com.epam.photographer.controllers;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.epam.photographer.DAO.DAOImpl;
import com.epam.photographer.DataBase.TempDataBase;
import com.epam.photographer.model.Album;
import com.epam.photographer.model.PhotoWrapper;
@Service
public class ServiceController {
	@Autowired
	private DAOImpl dao;
	
	public String getImage(int id){
		for (PhotoWrapper photo: TempDataBase.getPhotos()) {
			if(photo.getId() == id ){
				
				return photo.getUrl();
			}
		}
		
		
		return null;
	}
	 @Transactional
	public List<Album> getAlbums(){
		
		return TempDataBase.getAlbums();
		
	}
	
	 @Transactional
	public void setaddPhotoWrapper(PhotoWrapper photo){
		
		dao.addPhotoWrapper(photo);
		
	} 
	 @Transactional
	 public PhotoWrapper getPhoto(int Id){
		 return dao.getPhotoWrapperById(Id);
	 } 
}
